package com.itheima.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Member;
import com.itheima.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description 会员控制类
 * @Author makun
 * @Date 2023/9/16 10:58
 * @Version 1.0
 */
@RestController
@RequestMapping("/member")
public class MemberController {
    @Autowired
    private MemberService memberService;

    /**
     * 编辑会员档案
     * @param member
     * @return
     */
    @PutMapping
    public Result editMemberProfile(@RequestBody Member member){
        return Result.buildSuccess(memberService.edit(member));
    }
    /**
     * 删除会员档案
     * @param id
     * @return
     */
    @DeleteMapping
    public Result deleteMemberProfile(Integer id){
        return Result.buildSuccess(memberService.delete(id));
    }
    /**
     * 添加会员档案
     * @param member
     * @return
     */
    @PostMapping
    public Result addMemberProfile(@RequestBody Member member){
        return Result.buildSuccess(memberService.add(member));
    }

    /**
     * 获取会员档案
     * @param queryPageBean
     * @return
     */
    @GetMapping
    public Result getMemberProfiles(QueryPageBean queryPageBean){
        return Result.buildSuccess(memberService.findPage(queryPageBean));
    }
}
